<%@ page import="edu.uow.devdocs.Deployment" %>
<!doctype html>
<html>
	<head>
		<meta name="layout" content="main">
		<g:set var="entityName" value="${message(code: 'deployment.label', default: 'Deployment')}" />
		<title><g:message code="default.edit.label" args="[entityName]" /></title>
	</head>
	<body>
		<h1><g:message code="default.edit.label" args="[entityName]" /></h1>
		<div id="tabs">
			<ul>
				<li><a href="#tabDeployment">Deployment</a></li>
				<li><a href="#tabAssigned">Assigned</a></li>
				<li><a href="#tabTimeTracker">Track Time</a></li>
				<li><a href="#tabDevelopmentTasks">Development Tasks</a></li>
			</ul>
			<div id="tabDeployment" class="content scaffold-edit" role="main">
				<g:flashMessage/>
				<g:hasErrors bean="${deploymentInstance}">
				<ul class="errors" role="alert">
					<g:eachError bean="${deploymentInstance}" var="error">
					<li <g:if test="${error in org.springframework.validation.FieldError}">data-field-id="${error.field}"</g:if>><g:message error="${error}"/></li>
					</g:eachError>
				</ul>
				</g:hasErrors>
				<g:form method="post" class="columns">
					<g:hiddenField name="id" value="${deploymentInstance?.id}" />
					<g:hiddenField name="version" value="${deploymentInstance?.version}" />
					<g:render template="form"/>
					<fieldset class="form-actions">
						<g:actionSubmit class="save" action="update" value="${message(code: 'default.button.update.label', default: 'Update')}" />
						<g:actionSubmit class="delete" action="delete" value="${message(code: 'default.button.delete.label', default: 'Delete')}" formnovalidate="" onclick="return confirm('${message(code: 'default.button.delete.confirm.message', default: 'Are you sure?')}');" />
					</fieldset>
				</g:form>
			</div>
			<div id="tabAssigned">
				<g:render template="/shared/addAssignment" model="['deploymentId':deploymentInstance?.id,'projectId':deploymentInstance?.project.id]"/>
			</div>
			<div id="tabTimeTracker">
				<g:render template="/shared/addTimeTracker" model="['deploymentId':deploymentInstance?.id,'projectId':deploymentInstance?.project.id]"/>
			</div>
			<div id="tabDevelopmentTasks">
				<g:form controller="developmentChecklist" action="preview" target="_window" class="rows">
					<table class="sortable">
						<thead>
							<tr>
								<th><g:message code="developmentTask.task.label" default="Task" /></th>
								<th><g:message code="developmentChecklist.checklist.label" default="Checklist" /></th>
								<th><g:message code="developmentChecklist.status.label" default="Checklist Status" /></th>
								<th><g:message code="checklist.description.label" default="Checklist Type" /></th>
								<th>Preview</th>
							</tr>
						</thead>
					<g:each in="${edu.uow.devdocs.DevelopmentTask.findAllByDeployment(deploymentInstance)}" var="devTask">
						<tr>
							<td colspan="5"><g:link controller="developmentTask" action="show" id="${devTask.id}" > ${devTask?.task } - ${devTask.status }</g:link></td>
						</tr>
						<g:each in="${devTask?.developmentChecklists}" status="i" var="checklistItemInList">
						<tr>
							<td></td>
							<td>${fieldValue(bean: checklistItemInList, field: "description")}</td>
							<td>${fieldValue(bean: checklistItemInList, field: "status")}</td>
							<td>${fieldValue(bean: checklistItemInList, field: "checklist.description")}</td>
							<td><g:checkBox name="previewId" value="${checklistItemInList?.id}" /> </td>
						</tr>
						</g:each>
					</g:each>
					</table>
				<fieldset class="form-actions">
					<g:actionSubmit class="save" action="preview" value="${message(code: 'default.button.preview.label', default: 'Preview Selected')}" />
				</fieldset>
				</g:form>
			</div>
		</div>
		<script>
			$(function() {
					$("#tabs").tabs();
			});
		</script>
	</body>
</html>
